<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    let rnum = Math.floor(Math.random() * 10 + 1)
    // console.log(rnum)
    let flag = true
    for (let i = 1; i <= 3; i++) {
      let num = +prompt('请输入1-10之间的随机数字')

      if (num > rnum) {
        alert('数字猜大了，继续猜')
      } else if (num < rnum) {
        alert('数字猜小了，继续猜')
      } else {
        flag = false
        alert('真棒！你猜对啦')
        break
      }
      // 
    }
    if (flag) {
      alert('次数已经用完了')
    }

  </script>
</body>

</html>